﻿<?xml version="1.0" encoding="utf-8" ?>

<cls:class
	name="UsbDescriptor"
	type="http://metalx.org/Usb/UsbDescriptor"
	xmlns="http://metalx.org/Program"
	xmlns:cls="http://metalx.org/Class"
	xmlns:var="http://metalx.org/Variable"
	xmlns:clsf="http://metalx.org/i386/Functions/Class"
	xmlns:date="http://metalx.org/i386/Functions/Date"
	xmlns:time="http://metalx.org/i386/Functions/Time"
	xmlns:clk="http://metalx.org/i386/Functions/Clock"
	xmlns:obj="http://metalx.org/i386/Functions/Object"
	xmlns:sys="http://metalx.org/i386/Functions/System"
	xmlns:cat="http://metalx.org/i386/Functions/Catalog"
	xmlns:str="http://metalx.org/i386/Functions/String"
	xmlns:int="http://metalx.org/i386/Functions/Integer"
	xmlns:bool="http://metalx.org/i386/Functions/Boolean"
	xmlns:lst="http://metalx.org/i386/Functions/List"
	xmlns:pcif="http://metalx.org/i386/Functions/Pci"
	xmlns:hex="http://metalx.org/i386/Functions/Hexadecimal"
	xmlns:mm="http://metalx.org/i386/Functions/MemoryManager"
	xmlns:cpu="http://metalx.org/Intel/80386/Operators"
	xmlns:op="http://metalx.org/Intel/80386/Operands"
	xmlns:math="http://metalx.org/Intel/80386/Math"
	xmlns:ari="http://metalx.org/Intel/80386/Arithmetic"
	xmlns:shift="http://metalx.org/Intel/80386/Shift"
	xmlns:imm="http://metalx.org/Intel/80386/Immediate"
	xmlns:usb="http://metalx.org/Usb/Ohci/Registers"
	xmlns:pci="http://metalx.org/Pc/Pci/Ports"
	xmlns:cfg="http://metalx.org/Pc/Pci/Configuration">

	<cls:field name="Address" type="http://metalx.org/Hexadecimal" offset="0"/>

	<cls:method name="ToString" type="http://metalx.org/String">
		<cpu:CopyRegisterToOperand/>
		<op:DI-SIRegister/>

		<obj:GetData/>

		<cpu:CopyOperandToRegister/>
		<op:SI-SIAddress/>

		<cpu:IncrementSI/>

		<cpu:MathImmediateToOperandFunction8/>
		<math:CompareWithSIAddress/>
		<byte>1</byte>

		<cpu:BranchToRelative8IfNotEqual/>
		<addressOf ref="notDevice" type="Relative8"/>

		<cpu:CopyImmediateToDI/>
		<addressOf ref="deviceDescriptor" type="Absolute32"/>

		<cpu:JumpToRelative8/>
		<addressOf ref="createObject" type="Relative8"/>

		<label id="notDevice"/>

		<cpu:MathImmediateToOperandFunction8/>
		<math:CompareWithSIAddress/>
		<byte>2</byte>

		<cpu:BranchToRelative8IfNotEqual/>
		<addressOf ref="notConfiguration" type="Relative8"/>

		<cpu:CopyImmediateToDI/>
		<addressOf ref="configurationDescriptor" type="Absolute32"/>

		<cpu:JumpToRelative8/>
		<addressOf ref="createObject" type="Relative8"/>

		<label id="notConfiguration"/>

		<cpu:MathImmediateToOperandFunction8/>
		<math:CompareWithSIAddress/>
		<byte>4</byte>

		<cpu:BranchToRelative8IfNotEqual/>
		<addressOf ref="notInterface" type="Relative8"/>

		<cpu:CopyImmediateToDI/>
		<addressOf ref="interfaceDescriptor" type="Absolute32"/>

		<cpu:JumpToRelative8/>
		<addressOf ref="createObject" type="Relative8"/>

		<label id="notInterface"/>

		<cpu:MathImmediateToOperandFunction8/>
		<math:CompareWithSIAddress/>
		<byte>5</byte>

		<cpu:BranchToRelative8IfNotEqual/>
		<addressOf ref="notEndpoint" type="Relative8"/>

		<cpu:CopyImmediateToDI/>
		<addressOf ref="endpointDescriptor" type="Absolute32"/>

		<cpu:JumpToRelative8/>
		<addressOf ref="createObject" type="Relative8"/>

		<label id="notEndpoint"/>

		<cpu:CopyImmediateToDI/>
		<addressOf ref="usbDescriptor" type="Absolute32"/>

		<label id="createObject"/>

		<str:CreateObject/>

		<cpu:ReturnToNearCaller/>

		<var:string id="usbDescriptor">USB Descriptor</var:string>
		<var:string id="deviceDescriptor">USB Device Descriptor</var:string>
		<var:string id="configurationDescriptor">USB Configuration Descriptor</var:string>
		<var:string id="interfaceDescriptor">USB Interface Descriptor</var:string>
		<var:string id="endpointDescriptor">USB Endpoint Descriptor</var:string>
	</cls:method>

	<cls:method name="GetClass" type="http://metalx.org/Class">
		<cpu:CopyRegisterToOperand/>
		<op:DI-SIRegister/>

		<obj:GetType/>

		<cpu:CopyRegisterToOperand/>
		<op:SI-DIRegister/>

		<clsf:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="GetClass" type="http://metalx.org/Class" static="true">
		<cpu:CopyRegisterToOperand/>
		<op:BX-DIRegister/>

		<clsf:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>
</cls:class>